<template>
  <view class="buy-section" @click.stop="handleBuy">
    <view class="cart-buy" v-if="buyStyle == 'cart'">
      <image
        v-if="propsData.params.buyBtnImg"
        style="width: 48rpx; height: 48rpx"
        :src="propsData.params.buyBtnImg"
        mode=""
      />
      <i v-else class="iconfont icon-cart-full"></i>
    </view>
    <view class="add-buy" v-if="buyStyle == 'add'">
      <i class="iconfont icon-add-select"></i>
    </view>
    <view class="word-buy" v-if="buyStyle == 'word'">
      <text>{{ buyBtnText }}</text>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    propsData: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  computed: {
    buyStyle() {
      return this.propsData.params.buyStyle;
    },
    buyBtnText() {
      return this.propsData.params.buyBtnText;
    },
  },
  methods: {
    handleBuy() {
      this.$emit("handleBuy");
    },
  },
};
</script>

<style scoped lang="scss">
.buy-section {
  width: 100%;
  .cart-buy {
    .iconfont {
      font-size: 50rpx;
      color: #333333;
    }
  }
  .add-buy {
    width: 48rpx;
    height: 48rpx;
    background: #fa2c1b;
    border-radius: 16rpx;
    display: flex;
    justify-content: center;
    align-items: center;
    .iconfont {
      font-size: 40rpx;
      color: #ffffff;
    }
  }
  .word-buy {
    height: 6.4vw;
    padding: 0 2.67vw;
    font-size: 24rpx;
    font-family: PingFang SC;
    font-weight: 400;
    color: #ffffff;
    display: flex;
    justify-items: center;
    align-items: center;
    background: #fa2c1b;
    border-radius: 3.2vw;
  }
}
</style>
